home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / clients / editres / editres.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-12  |  4.4 KB  |  139 lines

  1. /*
  2.  * $XConsortium: editres.c,v 1.13 91/07/08 11:54:32 rws Exp $
  3.  *
  4.  * Copyright 1989 Massachusetts Institute of Technology
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of M.I.T. not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  M.I.T. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  */
  23.  
  24. #include <stdio.h>
  25. #ifdef MSDOS
  26. #include "X11/Intrinsc.h"      /* QDK 05/11/1994 12:54pm. */
  27. #else
  28. #include "X11/Intrinsic.h"
  29. #endif
  30. #include <X11/StringDefs.h>
  31.  
  32. #include <X11/Xaw/Cardinals.h>    
  33.  
  34. #define THIS_IS_MAIN        /* Don't get extern definitions of global
  35.                    variables. */
  36.  
  37. #include "editresP.h"
  38.  
  39. /*
  40.  * Global variables. 
  41.  */
  42.  
  43. int global_error_code;
  44. unsigned long global_serial_num;
  45. int (*global_old_error_handler)();
  46.  
  47. Boolean global_resource_box_up = FALSE;
  48. TreeInfo *global_tree_info = NULL;
  49. CurrentClient global_client;
  50. ScreenData global_screen_data;
  51. Widget global_tree_parent;
  52. AppResources global_resources;
  53.  
  54. extern void InternAtoms(), SetMessage(), BuildWidgetTree();
  55. extern void SetApplicationActions();
  56.  
  57. static void Syntax();
  58.  
  59. String fallback_resources[] = { 
  60.     NULL,
  61. };
  62.  
  63. #define Offset(field) (XtOffsetOf(AppResources, field))
  64.  
  65. static XtResource editres_resources[] = {
  66.   {"debug", "Debug", XtRBoolean, sizeof(Boolean),
  67.      Offset(debug), XtRImmediate, (XtPointer) FALSE},
  68.   {"numFlashes", "NumFlashes", XtRInt, sizeof(int),
  69.      Offset(num_flashes), XtRImmediate, (XtPointer) NUM_FLASHES},       
  70.   {"flashTime", "FlashTime", XtRInt, sizeof(int),
  71.      Offset(flash_time), XtRImmediate, (XtPointer) FLASH_TIME},       
  72.   {"flashColor", XtCForeground, XtRPixel, sizeof(Pixel),
  73.      Offset(flash_color), XtRImmediate, (XtPointer) XtDefaultForeground},
  74.   {"saveResourceFile", "SaveResourcesFile", XtRString, sizeof(String),
  75.      Offset(save_resources_file), XtRString, (XtPointer) ""},
  76. };
  77.  
  78. Atom wm_delete_window;
  79. Widget toplevel;
  80.  
  81. void
  82. main(argc, argv)
  83. int argc;
  84. char **argv;
  85. {
  86.     XtAppContext app_con;
  87.  
  88.     toplevel = XtAppInitialize(&app_con, "Editres", NULL, ZERO,
  89.                    &argc, argv, fallback_resources,
  90.                    NULL, ZERO);
  91.  
  92.     if (argc != 1)        
  93.     Syntax(app_con, argv[0]);
  94.  
  95.     SetApplicationActions(app_con);
  96.     XtGetApplicationResources(toplevel, (caddr_t) &global_resources, 
  97.                   editres_resources, XtNumber(editres_resources),
  98.                   NULL, (Cardinal) 0);
  99.     global_resources.allocated_save_resources_file = FALSE;
  100.  
  101.     XtOverrideTranslations
  102.       (toplevel, XtParseTranslationTable ("<Message>WM_PROTOCOLS: quit()"));  
  103.  
  104.     BuildWidgetTree(toplevel);
  105.  
  106.     SetMessage(global_screen_data.info_label, 
  107.            "Welcome to the X Resource Editor version 1.0");
  108.  
  109.     global_screen_data.set_values_popup = NULL;
  110.  
  111.     InternAtoms(XtDisplay(toplevel));
  112.  
  113.     XtRealizeWidget(toplevel);
  114.  
  115.     wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW",
  116.                    False);
  117.     (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel),
  118.                             &wm_delete_window, 1);
  119.     XtAppMainLoop(app_con);
  120. }
  121.  
  122. /*    Function Name: Syntax
  123.  *    Description: Prints a the calling syntax for this function to stdout.
  124.  *    Arguments: app_con - the application context.
  125.  *                 call - the name of the application.
  126.  *    Returns: none - exits tho.
  127.  */
  128.  
  129. static void 
  130. Syntax(app_con, call)
  131. XtAppContext app_con;
  132. char *call;
  133. {
  134.     XtDestroyApplicationContext(app_con);
  135.     fprintf( stderr, "Usage: %s [ -vspace <value> ] [ -hspace <value> ]\n",
  136.         call);
  137.     exit(1);
  138. }
  139.